<template>
  <div class="top-bar">
    <div class="status-bar" :style="{ height: `${statusBarHeight}px` }"></div>
    <div class="nav-bar">
      <div class="left">
        <div class="img-div" v-if="leftSrc" @click="leftClick()">
          <img class="img" :src="leftSrc" />
        </div>
        <div class="title max-text">{{ title }}</div>
      </div>
      <div class="img-div" v-if="rightSrc" @click="rightClick()">
        <img class="img" :src="rightSrc" />
      </div>
    </div>
  </div>
</template>
<script>
import storeManage from "../pages/store/index";
export default {
  name: "TopBar",
  data() {
    return {
      statusBarHeight: storeManage.state.statusBarHeight,
    };
  },
  props: {
    title: {
      type: String,
      default: "",
    },
    leftSrc: {
      type: String,
      default: "",
    },
    rightSrc: {
      type: String,
      default: "",
    },
  },
  created() {},
  methods: {
    leftClick() {
      this.$emit("leftClick");
    },
    rightClick() {
      this.$emit("rightClick");
    },
    getTopBarHeigth() {
      return this.statusBarHeight + 56;
    },
  },
};
</script>

<style lang="less" >
.top-bar {
  width: 100%;
  top: 0px;
  position: fixed;
  .status-bar {
    opacity: 0.5;
    background-color: var(--textColorPrimaryInverse);
    width: 100%;
  }
  .nav-bar {
    display: flex;
    height: 56px;
    background-color: var(--textColorPrimaryInverse);
    align-items: center;
    justify-content: space-between;
    .left {
      display: flex;
      align-items: center;
    }
    .title {
      font-size: 20px;
      color: var(--font);
      max-width: 250px;
    }
    .img-div {
      width: 48px;
      height: 56px;
      align-items: center;
      display: flex;
      justify-content: center;

      .img {
        width: 24px;
        height: 24px;
      }
    }
  }
}
</style>
